<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="../js/vue.js"></script>
  <title>Document</title>
</head>

<body>
  <div id="app"></div>
  <template id="why">
    <div>
      <h2>{{message}}</h2>
      <h2>{{counter}}</h2>
      <div>
        <button @click="decrement">-</button>
        <button @click="increment">+</button>
      </div>
    </div>
  </template>
  <script>
    Vue.createApp({
      template: "#why",
      data() {
        return {
          message: "methods中的this",
          counter: 0
        }
      },
      methods: {
        decrement: () => {
          console.log(this);
          this.counter--;
        },
        increment() {
          console.log(this);
          this.counter++;
        }
      }
    }).mount("#app")
  </script>
</body>

</html>